<!doctype html>
<html lang="en">
<head>
    <!-- 引入Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <title>Hockey Hero Management</title>
</head>
<body>
<div class="container mt-5">
<?php if (isset($editMode)): ?>
    <form action="<?= base_url('hockey/update/' . esc($record['id'])) ?>" method="post" class="row g-3">
        <?= csrf_field() ?>

        <?php if (isset($errors)): ?>
            <div class="alert alert-danger col-12" role="alert">
                <?php foreach ($errors as $error): ?>
                    <p><?= esc($error) ?></p>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>

        <div class="col-md-6">
            <label for="name" class="form-label">Name</label>
            <input type="text" class="form-control" id="name" name="name" value="<?= esc($record['name']) ?>">
        </div>

        <div class="col-md-6">
            <label for="city" class="form-label">City</label>
            <input type="text" class="form-control" id="city" name="city" value="<?= esc($record['city']) ?>">
        </div>

        <div class="col-12">
            <label for="powers" class="form-label">Powers</label>
            <textarea class="form-control" id="powers" name="powers"><?= esc($record['powers']) ?></textarea>
        </div>

        <div class="col-md-6">
            <label for="weapon" class="form-label">Weapon</label>
            <input type="text" class="form-control" id="weapon" name="weapon" value="<?= esc($record['weapon']) ?>">
        </div>

        <div class="col-12">
            <button type="submit" class="btn btn-primary">Update Hero</button>
            <a href="<?= base_url('hockey/showme/' . esc($record['id'])) ?>" class="btn btn-secondary">Cancel</a>
        </div>
    </form>
<?php else: ?>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Field</th>
                <th>Value</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>ID</td>
                <td><?= esc($record['id']) ?></td>
            </tr>
            <tr>
                <td>Name</td>
                <td><?= esc($record['name']) ?></td>
            </tr>
            <tr>
                <td>City</td>
                <td><?= esc($record['city']) ?></td>
            </tr>
            <tr>
                <td>Powers</td>
                <td><?= esc($record['powers']) ?></td>
            </tr>
            <tr>
                <td>Weapon</td>
                <td><?= esc($record['weapon']) ?></td>
            </tr>
            <tr>
                <td>Image</td>
                <td><img src="/image/<?= esc($record['image']) ?>" alt="<?= esc($record['name']) ?>" class="img-fluid" style="max-width: 200px;"></td>
            </tr>
        </tbody>
    </table>
    <a href="#" id="editButton" class="btn btn-warning">Edit Hero</a>
<?php endif; ?>
</div>

<!-- 引入Bootstrap JS和依赖 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
</body>
</html>